// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.SearchableSnapshots
{
	public sealed class SearchableSnapshotsMountRequestParameters : RequestParameters<SearchableSnapshotsMountRequestParameters>
	{
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

		[JsonIgnore]
		public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }

		[JsonIgnore]
		public string? Storage { get => Q<string?>("storage"); set => Q("storage", value); }
	}

	public sealed partial class SearchableSnapshotsMountRequest : PlainRequestBase<SearchableSnapshotsMountRequestParameters>
	{
		public SearchableSnapshotsMountRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Clients.Elasticsearch.Name snapshot) : base(r => r.Required("repository", repository).Required("snapshot", snapshot))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.SearchableSnapshotsMount;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

		[JsonIgnore]
		public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }

		[JsonIgnore]
		public string? Storage { get => Q<string?>("storage"); set => Q("storage", value); }

		[JsonInclude]
		[JsonPropertyName("index")]
		public Elastic.Clients.Elasticsearch.IndexName Index { get; set; }

		[JsonInclude]
		[JsonPropertyName("renamed_index")]
		public Elastic.Clients.Elasticsearch.IndexName? RenamedIndex { get; set; }

		[JsonInclude]
		[JsonPropertyName("index_settings")]
		public Dictionary<string, object>? IndexSettings { get; set; }

		[JsonInclude]
		[JsonPropertyName("ignore_index_settings")]
		public IEnumerable<string>? IgnoreIndexSettings { get; set; }
	}

	public sealed partial class SearchableSnapshotsMountRequestDescriptor : RequestDescriptorBase<SearchableSnapshotsMountRequestDescriptor, SearchableSnapshotsMountRequestParameters>
	{
		internal SearchableSnapshotsMountRequestDescriptor(Action<SearchableSnapshotsMountRequestDescriptor> configure) => configure.Invoke(this);
		public SearchableSnapshotsMountRequestDescriptor(Elastic.Clients.Elasticsearch.Name repository, Elastic.Clients.Elasticsearch.Name snapshot) : base(r => r.Required("repository", repository).Required("snapshot", snapshot))
		{
		}

		internal SearchableSnapshotsMountRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.SearchableSnapshotsMount;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public SearchableSnapshotsMountRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? masterTimeout) => Qs("master_timeout", masterTimeout);
		public SearchableSnapshotsMountRequestDescriptor Storage(string? storage) => Qs("storage", storage);
		public SearchableSnapshotsMountRequestDescriptor WaitForCompletion(bool? waitForCompletion = true) => Qs("wait_for_completion", waitForCompletion);
		public SearchableSnapshotsMountRequestDescriptor Repository(Elastic.Clients.Elasticsearch.Name repository)
		{
			RouteValues.Required("repository", repository);
			return Self;
		}

		public SearchableSnapshotsMountRequestDescriptor Snapshot(Elastic.Clients.Elasticsearch.Name snapshot)
		{
			RouteValues.Required("snapshot", snapshot);
			return Self;
		}

		private IEnumerable<string>? IgnoreIndexSettingsValue { get; set; }

		private Elastic.Clients.Elasticsearch.IndexName IndexValue { get; set; }

		private Dictionary<string, object>? IndexSettingsValue { get; set; }

		private Elastic.Clients.Elasticsearch.IndexName? RenamedIndexValue { get; set; }

		public SearchableSnapshotsMountRequestDescriptor IgnoreIndexSettings(IEnumerable<string>? ignoreIndexSettings)
		{
			IgnoreIndexSettingsValue = ignoreIndexSettings;
			return Self;
		}

		public SearchableSnapshotsMountRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			IndexValue = index;
			return Self;
		}

		public SearchableSnapshotsMountRequestDescriptor IndexSettings(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
		{
			IndexSettingsValue = selector?.Invoke(new FluentDictionary<string, object>());
			return Self;
		}

		public SearchableSnapshotsMountRequestDescriptor RenamedIndex(Elastic.Clients.Elasticsearch.IndexName? renamedIndex)
		{
			RenamedIndexValue = renamedIndex;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (IgnoreIndexSettingsValue is not null)
			{
				writer.WritePropertyName("ignore_index_settings");
				JsonSerializer.Serialize(writer, IgnoreIndexSettingsValue, options);
			}

			writer.WritePropertyName("index");
			JsonSerializer.Serialize(writer, IndexValue, options);
			if (IndexSettingsValue is not null)
			{
				writer.WritePropertyName("index_settings");
				JsonSerializer.Serialize(writer, IndexSettingsValue, options);
			}

			if (RenamedIndexValue is not null)
			{
				writer.WritePropertyName("renamed_index");
				JsonSerializer.Serialize(writer, RenamedIndexValue, options);
			}

			writer.WriteEndObject();
		}
	}
}